define(function(required, exports, modules) {
  var modal = require("mods/modal");
  var _csrf = $("#csrf").val();
  exports.member_editor_status = function() {
    $(".member_status").click(function() {
      var member_id = $(this).attr("data-id");
      var member_status = $(this).attr("data-status");
      if (member_status == "1") {
        modal.alert("用户已经认证通过");
        return false;
      }
      if (member_status == "0") {
        modal.confirm(
          "确定要认证此用户吗?",
          {},
          function() {
            $.ajax({
              url: "/admin/member/ops",
              type: "POST",
              dataType: "json",
              data: {
                _csrf: _csrf,
                member_id: member_id,
                func: "renzhen"
              },
              success: function(res) {
                if (res.code == 200) {
                  modal.msg(res.msg, {}, function() {
                    window.location.reload();
                  });
                } else {
                  modal.alert(res.msg);
                  return false;
                }
              }
            });
          },
          function() {}
        );
      }
    });
  };

  exports.member_del = function() {
    $("._del").click(function() {
      var member_id = $(this).attr("data-id");
      modal.confirm(
        "确定要删除此用户吗?",
        {},
        function() {
          $.ajax({
            url: "/admin/member/ops",
            type: "POST",
            dataType: "json",
            data: {
              _csrf: _csrf,
              member_id: member_id,
              func: "del"
            },
            success: function(res) {
              if (res.code == 200) {
                modal.msg(res.msg, {}, function() {
                  window.location.reload();
                });
              } else {
                modal.alert(res.msg);
                return false;
              }
            }
          });
        },
        function() {}
      );
    });
  };

  exports.search_member = function() {
    $(".search").click(function() {
      $(".member_search").submit();
    });
  };
});
